home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / turbovis / tvtool17.zip / INPUT.H < prev    next >
C/C++ Source or Header  |  1993-09-23  |  11KB  |  439 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. class TStreamable;
  4. #include <values.h>
  5. #include "strings.h"
  6.  
  7.  
  8. #if defined(Uses_TInputKey) && ! defined(__TInputKey)
  9. #define __TInputKey
  10. // Same as TInputLine, except invalid if empty
  11.  
  12. class TInputKey : public TInputLine
  13. {
  14.  
  15. public:
  16.  
  17.     TInputKey( const TRect&, int len );
  18.     TInputKey( int x, int y, int len );
  19.     virtual Boolean valid( ushort );
  20.  
  21. protected:
  22.  
  23.     TInputKey( StreamableInit ) : TInputLine( streamableInit ) {};
  24.  
  25. private:
  26.  
  27.     virtual const char *streamableName() const
  28.         { return name; }
  29.  
  30. public:
  31.  
  32.     static const char * const name;
  33.     static TStreamable *build();
  34.  
  35. };
  36.  
  37.  
  38. inline ipstream& operator >> ( ipstream& is, TInputKey& cl )
  39.     { return is >> (TStreamable&)cl; }
  40. inline ipstream& operator >> ( ipstream& is, TInputKey*& cl )
  41.     { return is >> (void *&)cl; }
  42. inline opstream& operator << ( opstream& os, TInputKey& cl )
  43.     { return os << (TStreamable&)cl; }
  44. inline opstream& operator << ( opstream& os, TInputKey* cl )
  45.     { return os << (TStreamable *)cl; }
  46.  
  47. #endif // Uses_TInputKey
  48.  
  49.  
  50.  
  51. #if defined(Uses_TInputPasswd) && ! defined(__TInputPasswd)
  52. #define __TInputPasswd
  53. // Same as TInputLine, but display only '*'
  54.  
  55. class TInputPasswd : public TInputLine
  56. {
  57.  
  58. public:
  59.  
  60.     TInputPasswd( const TRect&, int len );
  61.     TInputPasswd( int x, int y, int len );
  62.     virtual void draw( void );
  63.  
  64. protected:
  65.  
  66.     TInputPasswd( StreamableInit ) : TInputLine( streamableInit ) {};
  67.  
  68. private:
  69.  
  70.     virtual const char *streamableName() const
  71.         { return name; }
  72.  
  73. public:
  74.  
  75.     static const char * const name;
  76.     static TStreamable *build();
  77.  
  78. };
  79.  
  80.  
  81. inline ipstream& operator >> ( ipstream& is, TInputPasswd& cl )
  82.     { return is >> (TStreamable&)cl; }
  83. inline ipstream& operator >> ( ipstream& is, TInputPasswd*& cl )
  84.     { return is >> (void *&)cl; }
  85. inline opstream& operator << ( opstream& os, TInputPasswd& cl )
  86.     { return os << (TStreamable&)cl; }
  87. inline opstream& operator << ( opstream& os, TInputPasswd* cl )
  88.     { return os << (TStreamable *)cl; }
  89.  
  90.  
  91. ushort inputPasswdBoxRect( const TRect &bounds,
  92.                            const char *Title,
  93.                            const char *aLabel,
  94.                            char *s,
  95.                            uchar limit );
  96.  
  97.  
  98. ushort inputPasswdBox( const char *Title, const char *aLabel, char *s, uchar limit );
  99.  
  100.  
  101. #endif // Uses_TInputPasswd
  102.  
  103.  
  104.  
  105. #if defined(Uses_TInputRegExp) && ! defined(__TInputRegExp)
  106. #define __TInputRegExp
  107. // Accepts only regular expression-matching input
  108.  
  109. class TInputRegExp: public TInputLine
  110. {
  111.  
  112. public:
  113.  
  114. #pragma warn -bei
  115.     TInputRegExp( const TRect&, int , const char * = 0, const char * = 0, casetype = 0 );
  116.     TInputRegExp( int x, int y, int , const char * = 0, const char * = 0, casetype = 0 );
  117.     virtual ~TInputRegExp();
  118.     virtual void setState( ushort, Boolean );
  119.     virtual void handleEvent( TEvent& );
  120.     virtual Boolean valid( ushort );
  121.  
  122. protected:
  123.  
  124.     TInputRegExp( StreamableInit ) : TInputLine( streamableInit ) {};
  125.  
  126. private:
  127.  
  128.     virtual void init( const char *aSet, const char *aRegexp, casetype aNewcase );
  129.     char *set, *regexp;
  130.     casetype newcase;
  131.  
  132.     virtual const char *streamableName() const
  133.         { return name; }
  134.  
  135. public:
  136.  
  137.     static const char * const name;
  138.     static TStreamable *build();
  139.     static char *invMsg;
  140. };
  141.  
  142.  
  143. inline ipstream& operator >> ( ipstream& is, TInputRegExp& cl )
  144.     { return is >> (TStreamable&)cl; }
  145. inline ipstream& operator >> ( ipstream& is, TInputRegExp*& cl )
  146.     { return is >> (void *&)cl; }
  147. inline opstream& operator << ( opstream& os, TInputRegExp& cl )
  148.     { return os << (TStreamable&)cl; }
  149. inline opstream& operator << ( opstream& os, TInputRegExp* cl )
  150.     { return os << (TStreamable *)cl; }
  151.  
  152. #endif //  Uses_TInputRegExp
  153.  
  154.  
  155. #if defined(Uses_TInputInt) && ! defined(__TInputInt)
  156. #define __TInputInt
  157. // Accepts only valid numeric input (int) between Min and Max
  158.  
  159. class TInputInt : public TInputRegExp
  160. {
  161.  
  162. public:
  163.  
  164.     TInputInt( const TRect&, int len = 7, int min = -MAXINT, int max = MAXINT );
  165.     TInputInt( int x, int y, int len = 7, int min = -MAXINT, int max = MAXINT );
  166.     virtual ushort dataSize();
  167.     virtual void getData( void *);
  168.     virtual void setData( void *);
  169.     virtual Boolean valid( ushort );
  170.     int min;
  171.     int max;
  172.  
  173. protected:
  174.  
  175.     TInputInt( StreamableInit ) : TInputRegExp( streamableInit ) {};
  176.     virtual void write( opstream& );
  177.     virtual void *read( ipstream& );
  178.  
  179. private:
  180.  
  181.     virtual const char *streamableName() const
  182.         { return name; }
  183.  
  184. public:
  185.  
  186.     static const char * const name;
  187.     static TStreamable *build();
  188.  
  189. };
  190.  
  191. inline ipstream& operator >> ( ipstream& is, TInputInt& cl )
  192.     { return is >> (TStreamable&)cl; }
  193. inline ipstream& operator >> ( ipstream& is, TInputInt*& cl )
  194.     { return is >> (void *&)cl; }
  195. inline opstream& operator << ( opstream& os, TInputInt& cl )
  196.     { return os << (TStreamable&)cl; }
  197. inline opstream& operator << ( opstream& os, TInputInt* cl )
  198.     { return os << (TStreamable *)cl; }
  199.  
  200. #endif // Uses_TInputInt
  201.  
  202.  
  203.  
  204.  
  205.  
  206. #if defined(Uses_TInputLong) && ! defined(__TInputLong)
  207. #define __TInputLong
  208. // Accepts only valid numeric input (long) between Min and Max
  209.  
  210. class TInputLong : public TInputRegExp
  211. {
  212.  
  213. public:
  214.  
  215.     TInputLong( const TRect&, int len = 12, long min = -MAXLONG, long max = MAXLONG );
  216.     TInputLong( int x, int y, int len = 12, long min = -MAXLONG, long max = MAXLONG );
  217.     virtual ushort dataSize();
  218.     virtual void getData( void *);
  219.     virtual void setData( void *);
  220.     virtual Boolean valid( ushort );
  221.     long min;
  222.     long max;
  223.  
  224. protected:
  225.  
  226.     TInputLong( StreamableInit ) : TInputRegExp( streamableInit ) {};
  227.     virtual void write( opstream& );
  228.     virtual void *read( ipstream& );
  229.  
  230. private:
  231.  
  232.     virtual const char *streamableName() const
  233.         { return name; }
  234.  
  235. public:
  236.  
  237.     static const char * const name;
  238.     static TStreamable *build();
  239.  
  240. };
  241.  
  242. inline ipstream& operator >> ( ipstream& is, TInputLong& cl )
  243.     { return is >> (TStreamable&)cl; }
  244. inline ipstream& operator >> ( ipstream& is, TInputLong*& cl )
  245.     { return is >> (void *&)cl; }
  246. inline opstream& operator << ( opstream& os, TInputLong& cl )
  247.     { return os << (TStreamable&)cl; }
  248. inline opstream& operator << ( opstream& os, TInputLong* cl )
  249.     { return os << (TStreamable *)cl; }
  250.  
  251. #endif // Uses_TInputLong
  252.  
  253.  
  254.  
  255.  
  256.  
  257. #if defined(Uses_TInputDouble) && ! defined(__TInputDouble)
  258. #define __TInputDouble
  259. // Accepts only valid numeric input between Min and Max
  260.  
  261. class TInputDouble : public TInputRegExp
  262. {
  263.  
  264. public:
  265.  
  266.     TInputDouble( const TRect&, int len = 15, double min = -MAXDOUBLE, double max = MAXDOUBLE );
  267.     TInputDouble( int x, int y, int len = 15, double min = -MAXDOUBLE, double max = MAXDOUBLE );
  268.     virtual ushort dataSize();
  269.     virtual void getData( void *);
  270.     virtual void setData( void *);
  271.     virtual Boolean valid( ushort );
  272.     double min;
  273.     double max;
  274.  
  275. protected:
  276.  
  277.     TInputDouble( StreamableInit ) : TInputRegExp( streamableInit ) {};
  278.     virtual void write( opstream& );
  279.     virtual void *read( ipstream& );
  280.  
  281. private:
  282.  
  283.     virtual const char *streamableName() const
  284.         { return name; }
  285.  
  286. public:
  287.  
  288.     static const char * const name;
  289.     static TStreamable *build();
  290.  
  291. };
  292.  
  293. inline ipstream& operator >> ( ipstream& is, TInputDouble& cl )
  294.     { return is >> (TStreamable&)cl; }
  295. inline ipstream& operator >> ( ipstream& is, TInputDouble*& cl )
  296.     { return is >> (void *&)cl; }
  297. inline opstream& operator << ( opstream& os, TInputDouble& cl )
  298.     { return os << (TStreamable&)cl; }
  299. inline opstream& operator << ( opstream& os, TInputDouble* cl )
  300.     { return os << (TStreamable *)cl; }
  301.  
  302. #endif //  Uses_TInputDouble
  303.  
  304.  
  305.  
  306. #if defined(Uses_TInputHexa) && ! defined(__TInputHexa)
  307. #define __TInputHexa
  308. // Accepts only valid hexadecimal string input
  309.  
  310. class TInputHexa : public TInputRegExp
  311. {
  312.  
  313. public:
  314.  
  315.     TInputHexa( const TRect&, int len );
  316.